
<?php

define( API_URL, 'https://api.zeepmobile.com/messaging/2008-07-14/send_message' );
define( API_KEY, '06201b27-cf42-4fe4-a1d2-5c3bb9b6e4b8' );
define( SECRET_ACCESS_KEY, '2d5590618fe87c155803a522089ac2e88daf78cf' );

# (ex. Sat, 12 Jul 2008 09:04:28 GMT)
$http_date = gmdate( DATE_RFC822 );

$parameters = "user_id=".$_POST['uid']."&body=".$_POST['body'];
# => "user_id=1234&body=Art+thou+not+Romeo%2C+and+a+Montague%3F"

$canonical_string = API_KEY . $http_date . $parameters;
# => "YOUR_API_KEYSat, 12 Jul 2008 09:04:55GMTuser_id=1234&body=Art+thou+not+Romeo%2C+and+a+Montague%3F"

$b64_mac = base64_encode(hash_hmac("sha1", $canonical_string,SECRET_ACCESS_KEY, TRUE));

$authentication = "Zeep " . API_KEY . ":$b64_mac";

$header = array(
  "Authorization: ".$authentication,
  "Date: ".$http_date,
  "Content-Type: application/x-www-form-urlencoded",
  "Content-Length: " . strval(strlen($parameters))
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, API_URL );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters );
$response = curl_exec($ch);
curl_close($ch);

?>